Repository navigation
readline: do not read history options from the input stream - #67665
Open
yohannesjoya wants to merge 1 commit into
Open
yohannesjoya wants to merge 1 commit into
yohannesjoya wants to merge 1 commit into
Conversation
When createInterface() is given a stream instead of an options object, the stream itself was passed to setupHistoryManager() as the history options. A stream with an onHistoryFileLoaded property, such as a mock, started REPL history loading before this.input was set and threw "Cannot read properties of undefined (reading 'pause')". Properties named history or size on the stream were validated as history options too. Pass empty history options in that case, as before v24.2.0. History given in an options object is unchanged. Fixes: nodejs#61526 Refs: nodejs#61538 Signed-off-by: Yohannes Desta <yohannesdestagebru10@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67665 +/- ##
==========================================
- Coverage 92.99% 90.59% -2.41%
==========================================
Files 428 801 +373
Lines 195633 280968 +85335
Branches 30281 54234 +23953
==========================================
+ Hits 181937 254537 +72600
- Misses 13369 16621 +3252
- Partials 327 9810 +9483
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
readline.createInterface()is given a stream rather than an options object, the stream itself is passed tosetupHistoryManager()as the REPL history options. A stream with anonHistoryFileLoadedproperty, such as a mocked stream, starts REPL history loading beforethis.inputis set and throwsCannot read properties of undefined (reading 'pause'), and a stream with ahistoryorsizeproperty is validated as history options. Both work on v22 and fail since v24.2.0; reproduced on main.This passes empty history options when only a stream is given, which matches the behaviour before v24.2.0. History passed in an options object is unchanged, and the REPL sets its history separately through
setupHistory(). @thisalihassan noted on #61538 that the root cause is readline passing the input to the REPL history setup; this addresses that directly. The new test fails on main with the TypeError from the issue and passes with this change; the readline and REPL tests pass locally.Fixes: #61526
Refs: #61538
AI disclosure: I used a coding agent to help find the issue and draft the test. I reproduced the crash on v25 and main, reviewed the change line by line, and ran the readline and REPL tests locally.